package com.aaa.service.impl;

import com.aaa.dao.EmpDao;
import com.aaa.entity.Emp;
import com.aaa.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Predicate;

@Service
public class EmpServiceimpl implements EmpService {
    @Autowired
    private EmpDao empDao;


    @Override
    public List<Emp> queryAll() {
        List<Emp> emps = empDao.selAll();
        System.out.println("-----------------------------------------------");
        //取出大于8岁的人
//        emps.stream().filter(emp -> emp.getAge()>=8).limit(3).forEach(System.out::println);
        emps.stream().filter(emp -> emp.getAge()>=8).limit(3).sorted((o1, o2) ->o2.getAge()- o1.getAge()).forEach(System.out::println);
        //取出前3
//        emps.stream().limit(3).forEach(System.out::println);

        return emps;
    }
}





































